package com.cee.admin.modules.sys.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cee.admin.common.BaseController;
import com.cee.common.core.query.BasePageQuery;
import com.cee.common.web.result.Result;
import com.cee.domain.modules.sys.entity.SysConfig;
import com.cee.ds.modules.sys.service.ISysConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * @author wsz
 * @since 2023/5/25
 */
@RestController
@Tag(name = "系统配置")
@RequestMapping("api/v1/sys/config")
public class SysConfigController extends BaseController {

    @Autowired
    private ISysConfigService sysConfigService;

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<Page<SysConfig>> page(BasePageQuery<SysConfig> basePageQuery) {
        return success(sysConfigService.page(basePageQuery.generatePage()));
    }

    @GetMapping("update")
    @Operation(summary = "更新配置")
    public Result<Boolean> update(@Valid @RequestBody SysConfig config)
    {
        return success(sysConfigService.updateById(config));
    }
}
